<template>
  <div id="role-info">
    <main-content :query-condition="queryCondition" :name="name" :table-head="tableHead" :buttons="buttons"
                  :edit-component-name="editComponent"></main-content>
  </div>
</template>

<script>
  import mainContent from '../../../common/main-content'
  import {mapState} from 'vuex'

  export default {
    computed: {
      ...mapState({
        buttons: state => state.manager.buttons
      })
    },
    mounted() {
      this.initQueryCondition()
    },
    methods: {
      initQueryCondition() {
        this.common.request({
          url: this.buttons.children[0].children[0].target,
          param: {
            parentId: '0',
          },
          permission: this.buttons.children[0].children[0].id,
          loading:false,
          success: res => {
            if (res.code == 1) {
              this.$set(this.queryCondition[2], 'options', this.common.isEmpty(res.data.rows) ? [] : res.data.rows)
            }
          }
        })
        this.$set(this.queryCondition[3], 'url', this.buttons.children[0].children[1].target)
        this.$set(this.queryCondition[3], 'permission', this.buttons.children[0].children[1].id)
        this.$set(this.queryCondition[4], 'url', this.buttons.children[0].children[2].target)
        this.$set(this.queryCondition[4], 'permission', this.buttons.children[0].children[2].id)
        this.$set(this.queryCondition[4], 'initValue', 'winfo_bd94a04c28e0ed11e9b6c954e1add85a5d')
        this.$set(this.queryCondition[5], 'url', this.buttons.children[0].children[3].target)
        this.$set(this.queryCondition[5], 'permission', this.buttons.children[0].children[3].id)
        this.$set(this.queryCondition[5], 'initValue', 'winfo_bd053d304ee0ef11e9b6c954e1add85a5d')
      }
    },
    components: {
      mainContent
    },
    name: "role-info",
    data() {
      return {
        editComponent: 'role-edit',
        name: '角色',
        isTreeTable: false,
        queryCondition: [{
          name: '角色名称',
          key: 'name',
          type: 'input'
        }, {
          name: '角色编号',
          key: 'code',
          type: 'input'
        },{
          name: '归属公司',
          key: 'companyId',
          type: 'select'
        },{
          name:'归属部门',
          key:'officeId',
          type:'union-select',
        },{
          name:'角色类型',
          key:'roleTypeId',
          type:'union-select'
        },{
          name:'数据范围',
          key:'dataPermissionId',
          type:'union-select'
        }],
        tableHead: [{
          name: '角色名称',
          key: 'name',
        }, {
          name: '角色编号',
          key: 'code',
        }, {
          name: '归属公司',
          key: 'company',
        }, {
          name: '归属部门',
          key: 'office',
        }, {
          name: '角色类型',
          key: 'roleType'
        }, {
          name: '角色数据权限',
          key: 'dataPermission',
        }],
      }
    },
    watch: {},


  }
</script>

<style scoped>

</style>
